package com.msh.artascope.devcloud.service.define;

import com.msh.frame.client.define.StringDef;

public class DevCloudDef {

  public static final String JOB_FORMAT = "%s_%s";

  public static final Integer FUZZY_SEARCH_TYPE_MODULE_NAME = 1;

  /**
   * 镜像名格式化 例 registry.msh.com/images/brick-web:5829bd3-3 docker服务器地址    构建模块名   git提交号  jenkins构建号
   */
  private static final String DOCKER_IMAGE_FORMAT = "%s/images/%s-%s:%s-%d";


  public static String getJobName(String namespace, String projectName) {
    return String.format(DevCloudDef.JOB_FORMAT, namespace, projectName);
  }

  public static String getDockerImage(String registerAddress, String moduleName, String namespace,
      String gitCommit, Integer jobNum) {
    moduleName = moduleName.toLowerCase();
    return String.format(DOCKER_IMAGE_FORMAT, registerAddress, moduleName, namespace, gitCommit,
        jobNum);
  }

  public static String getGatewayName(String domain) {
    return domain.replaceAll("\\.", "-");
  }

  public static String getDeployName(String mouduleName, Integer versionNum) {
    return mouduleName + "-v" + versionNum;
  }

  public static String getDeployName(String mouduleName, String version) {
    return mouduleName + "-" + version;
  }

  public static String getVersion(Integer versionNum) {
    return "v" + versionNum;
  }

  public static String getFormatPath(String path) {
    if (!path.startsWith(StringDef.SLASH)) {
      path = StringDef.SLASH + path;
    }
    if (!path.endsWith(StringDef.SLASH)) {
      path = path + StringDef.SLASH;
    }
    return path;
  }

  public static @interface Group1 {

  }

  public static @interface Group2 {

  }
}
